<?php
//------------------------------------------------------------------------------
// File               : V_SanphamList
// Modification       :
//------------------------------------------------------------------------------
// Date(yyyy.mm.dd)   Developer                       Action
//------------------------------------------------------------------------------
// 2007.03.15         Oanhhtk                         Created
//------------------------------------------------------------------------------

function V_SanphamList(&$arrayData,$action,$arrayData_catSanpham){
	global $LANG;
    $ulr = "?".MODUL."=sanpham&".ACTION."=";
?>
<?= CM_showError() ?> 
<?
    //phan trang
	$totalRows = 0;
	$curPage =1;
	$strStart =0;
	$strEnd=0;
	
	$totalRows=count($arrayData);

	$curPage =CM_getParameter("curPg");
	if(((int)$curPage)==0) $curPage =1;
	
	$totalPage = 	(int)($totalRows/50);
	if($totalRows % 50 > 0 ) $totalPage ++;
	
	if($totalRows >0){
		$strStart = ($curPage -1) * 50+1;
		$strEnd   = ($curPage )   * 50 ;
		if($strEnd  > $totalRows ) $strEnd  = $totalRows;
	}
?>	

<script>
function GotoPage(iPage) 
{
    document.frm.curPg.value=iPage;
    document.frm.submit()          ;
}
</script>


<table width="100%" cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td valign="top"  colspan="4"><span class="name_product"><a href="#"><?=$arrayData_catSanpham[0]['ten_loai_sp']?></a></span></td>
	</tr>
<form name="frm" action="../run/main.php?modul=sanpham&action=<?=$action?>"  method="post" >
	<?
		if(!empty($arrayData)){
			$curRow=0;
			$i=0;
			$j = count($arrayData);
			$count=0;
			foreach($arrayData as $row){
				$curRow ++;
				if( $curRow < $strStart ) continue;
				if( $curRow > $strEnd )  break;
				$i+=1;
				
				if($count==0){
	?>
	<tr>
	<?
				}//end if($count==0)
	?>
		
		<td valign="top" align="left" style="width:146px; border-right:1px solid #abdafd; <? if($j > 4){ ?> border-bottom:1px solid #ccc; <? } ?> <? if ($count==3){?> border-right:0px; <? } ?> " >
			
				<div class="sanpham">
					<ul class="khungsp">
						<li class="blue1"><a href="?modul=sanpham&action=View&id_loai_sp=<?=$row['id_loai_sp']?>&id=<?=$row['id']?>" class="blue2"><?=$row['ten_sp']?></a>
						<?
						if($i<3){
						?>
						<img src="../images/new.gif"  width="30" height="15" />
						<?
						}
						?>
						</li>
						<li class="sp">
						<?
							$Money = to_money($row['gia_sp']); 
							$money_detail = "$Money VNĐ";
							if($row['trang_thai']==1){
								$trang_thai ="Còn hàng";
							}else{
								$trang_thai = "Hết hàng";
							}
							$loai_tien = $row['loai_tien'];
							if($loai_tien==1){
								$cat_money = "VNĐ";
							}else{
								$cat_money = "USD";
							}
							$money_detail = "$Money $cat_money";
							
							$text = "<table width=300 cellpadding='0' cellspacing='0'><tr><td width=110><img src='".DIR_IMAGES_VIEW.$row['anh_sp']."' width=100px height=100px align=center /></td><td valign=top align=left><table width=100%><tr><td><font class=black>Giá bán: </font><font class=blue>".$money_detail."</font></td></tr><tr><td><font class='black'>Bảo hành: </font><font class=red>".$row['bao_hanh']." tháng</font></td></tr><tr><td><font class='black'>Nhà sản xuất: </font><font class=blue>".$row['nha_sx']."</font></td></tr><tr><td><font class='black'>Trạng thái: </font><font class=red>".$trang_thai."</font></td></tr></table></td></tr><tr><td colspan='2'  style='padding-top:10px; padding-left:5px; padding-right:5px; ' align=left><font class='black'><B>Chi tiết</B></font><br>".$row['mo_ta_sp']."</td></tr></table>";
						?>
						<a href="?modul=sanpham&action=View&id_loai_sp=<?=$row['id_loai_sp']?>&id=<?=$row['id']?>">
							<img src="<?=DIR_IMAGES_VIEW.$row['anh_sp']?>" width="100px" height="100px" title="cssheader=[boxover-cssheader] cssbody=[boxover-cssbody] header=[<?=$row['ten_sp']?>] body=[<?=$text?>]" />
						</a>
						</li>
						<li class="blue"><font class="black">Giá:</font>&nbsp;<? $Money = to_money($row['gia_sp']); print("$Money $cat_money");?> </li>
						<li class="red"><font class="black">Bảo hành:</font>&nbsp;<?=$row['bao_hanh']?>&nbsp;tháng</li>
						<li class="blue"><font class="black">Nhà sản xuất:</font>&nbsp;<?=$row['nha_sx']?></li>
					</ul>
				</div><!-- sanpham -->
			
		</td>
		
	<?
		$count+=1;
		if($count>3){
			$count=0;
			$j-=4;
	?>
	</tr>
	
	<?
		}//end if($count>3)
	?>
	<?
				
			}// end foreach
	?>
	<tr>
		<td colspan="4" style="padding-top:0px; margin:0px; ">
			<table width="100%" cellpadding="0" cellspacing="0">
				<tr>
					<td width="1%" valign="bottom" class="box_one">&nbsp;</td>
					<td valign="bottom" class="box_two">&nbsp;</td>
					<td width="1%" valign="bottom" class="box_three">&nbsp;</td>
				</tr>
			</table>
		</td>
		
	</tr>
	<?
		
			if($totalPage>1){		
		?>
		<tr>
			<td colspan="4">
			
		<?
				echo "<font style=\"font-size:14px;\">Trang: </font>";		
				for($i=1;$i<= $totalPage;$i++){ 
					if($i != $curPage) echo "<font style=\"font-size:14px;\"><a href=\"javascript:GotoPage('$i')\" style=\"color:#000000; text-decoration:underline;\">$i</a></font>  ";
					else 			   echo "<SPAN class=bk12-140 style=\"color:#FF0000; font-size:16px;\">$i  </SPAN> " ;
				}
			}// enf if($totalPage>1)
		?>
		</td>
	</tr>
	<?
		}else{
	?>
	<tr>
		<td colspan="4" style="padding:20px; text-align:center; font-family:tahoma; font-size:12px; ">
			Không có sản phẩm nào.
		</td>
	</tr>
	<?
		}
	?>
<input type=hidden  name="curPg"  value="0" >
<input type=hidden  name="id"  value="<?=CM_getParameter('id')?>" >
<input type=hidden  name="textfield"  value="<?=CM_getParameter('textfield')?>" >
</form>		
</table>




<?php
foreach ($_POST as $key => $value) {
		$value = htmlspecialchars( CM_getParameter($key));
		echo '<input type=hidden  name="'.$key.'"  value="'.$value.'" >';
		echo "\n";
	}
}
?>